/************init.html************/
function queryMyClass() {
	var name = $("#className").val();
	var parm = {"name":name};
	var url = create_url('myClass-query');
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#myClassInfoResultList').html(result);
		}
	});
}

$('#className').keydown(function(event) {
	if(event.keyCode == '13') {
		queryMyClass();
		return false;
	}
});
function showMaterialAndExam(code,cc,i) {
	var parm = {"code":code,'cc':cc};
	var url = create_url('myClass-showMaterialAndExam');
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#courseList_'+i).html(result);
		}
	});
}


//开始学习培训资料
function learnMaterialAnnex(clc, cc, tmc, tmac, learnUrl){
	if(clc == '' || cc == '' || tmc == '' || tmac == '' || learnUrl == ''){
		sys_msg("学习资料读取失败，请刷新后重试!");
		return;
	}
	var url = create_url('myClass-learnMaterialAnnex')
	+ "&clc=" + clc + "&cc=" + cc + "&tmc=" + tmc
	+ "&tmac=" + tmac + "&learnUrl=" + learnUrl;
	window.open(url);
	
}

/*************edit.html**************/
//开始考试
function exam(classCode, courseCode, kk, yk){
	if(kk <= yk){
		sys_msg('已达到最大考试次数');
		return;
	}
	if(courseCode != '' && classCode != ''){
		$.Zebra_Dialog('考试开始后中途不能退出，确认开始考试吗？',{
			'type': 'question','title': '警告' ,'buttons':[
	           {caption:'确认',callback:function() {
	        	   var parm = {'classCode':classCode, 'courseCode':courseCode};
	        	   var url = create_url('myClass-exam');
	        	   $.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'950px', height:'760px', open:true, escKey:false, overlayClose:false,
	        		   overlayClose:false,onLoad: function() {
	        			   $('#cboxClose').remove();
	        		   }
	        	   });
	           }},
	           {caption:'取消',callback:function(){}
	       }]
		});
	}else{
		sys_msg('试卷生成失败，请刷新后重试!');
	}
}

//查看考试记录
function openExamRecord(code){
	var parm = {'code':code};
	var url = create_url('myClass-openExamRecord');
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'950px', height:'760px', open:true});
}

function download_myClass(path, code) {
	window.location.href = path + 'm/myClass-download_' + code + ".html";
}

/**
 * 受训报告
 */
function openTrainedReport(clc){
	var url = create_url("trainedReport-reportStudent");
	var parm = {"clc" : clc};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'650px', height:'600px', open:true});
}
